package com.etoc.test.quartz;


import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;



/**
 * 
 * spring管理注入 (让直行任务的job类可以用注解注入实体)
 *
 * @author  	 朱鹏
 * @version  	[版本号, 2017年3月22日]
 * @see  		com.etoc.isp.quartz.job.SyncOrderQuartzJob
 * @see			com.etoc.isp.quartz.job.SyncOvertimeQuartzJob
 * @since  		[产品/模块版本]
 */
@Component(value="JobFactory")
public class JobFactory extends AdaptableJobFactory {
	
	@Autowired  
    private AutowireCapableBeanFactory capableBeanFactory;  
  
    @Override  
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {  
        //调用父类的方法  
        Object jobInstance = super.createJobInstance(bundle);  
        //进行注入  
        capableBeanFactory.autowireBean(jobInstance);  
        return jobInstance;  
    }
    
}
